package edu.hrbu.spring.controller;

import edu.hrbu.spring.exception.BusinessException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author 徐登宇
 */
@Controller
@RequestMapping("/test")
public class TestController {

    @RequestMapping("/ex1")
    public String testEx1() {
        int i=1/0;
        return "file/index";
    }

    @RequestMapping("/ex2/{id}")
    public String testEx2(@PathVariable("id") int id) throws BusinessException {
        if (id%2==0){
            throw new BusinessException("服务器崩了");
        } else {
            return "file/index";
        }


    }

}
